# -*- mode: Makefile; -*-
# ----------------------------------------------------------------------------
include ../SETTINGS
include ../doc/SETTINGS
# ----------------------------------------------------------------------------
# This is the only variable which has to be set; then type 'gmake readmes'
# These files must have no suffix and be written in lpdoc format
# 
READMES = README INSTALL 
# ----------------------------------------------------------------------------

# (leave old FILEPATHS in front to avoid loops)
FILEPATHS := . $(FILEPATHS)
COMPONENTS = $(addsuffix .pl,$(READMES))
INDICES    = # Leave emty!
MAIN       = # Leave emty!
TARGETS    = $(addsuffix .readme,$(READMES))
MESSAGE=[WARNING: do not edit, file automatically generated by lpdoc/texinfo]

readmes: $(TARGETS)

.SUFFIXES: .readme .lpdoc

%.readme: %.lpdoc
	@$(ECHO) "*** --------------------------------------------------------"
	@$(ECHO) "*** Generating $* in ascii format using lpdoc/texinfo ..."
	@$(ECHO) "*** --------------------------------------------------------"
	@$(ECHO) "*** --------------------------------------------------------"
	@$(ECHO) "*** Generating $*.pl from $*.lpdoc ..."
	@$(ECHO) "*** --------------------------------------------------------"
	@echo ":- use_package([assertions])."                > $*.pl
	@echo ":- comment(title,\"$*\"). "                   >> $*.pl
	@echo ":- comment(module,\"@include{$*.lpdoc}\")." >> $*.pl
	@echo "main."                                        >> $*.pl
	$(MAKE) $*.ascii
	@$(ECHO) "*** --------------------------------------------------------"
	@$(ECHO) "*** Installing $* in $(SRC) ..."
	@$(ECHO) "*** --------------------------------------------------------"
	@echo $(MESSAGE) > $(SRC)/$*
	@echo " "       >> $(SRC)/$*
	cat $*.ascii    >> $(SRC)/$*
	-chmod $(DATAMODE) $(SRC)/$*
	@$(ECHO) "*** --------------------------------------------------------"
	@$(ECHO) "*** Cleaning up ..."
	@$(ECHO) "*** --------------------------------------------------------"
	$(MAKE) braveclean
	'rm' -f $*.itf
	'rm' -f $*.pl
	'rm' -f $*.asr
	-ln -s $(SRC)/$* $*.readme
# ----------------------------------------------------------------------------



